<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%> 
 <% String projectId = (String)request.getAttribute("projectId"); 
 	String path=request.getContextPath();
 %>
<html:html> 
	<head>
		<title>CGProject</title>
		
		<script lanuage="javascript">
			var name = "";
			function showUser(id){
				var users=new Array();
				var tds=document.getElementsByTagName("td");
				for(var j=0;j<tds.length;j++){
					if(tds[j].getAttribute("name")==id){
						users.push(tds[j]);
					}
				}
				var img=document.getElementById(id);
				var imgsrc=img.src;
				if(imgsrc.indexOf("open.jpg")!=-1){
					img.src="<%=path%>/images/close.jpg";
					for(var i=0;i<users.length;i++){
						users[i].parentNode.style.display="none";
					}
				}else{
					img.src="<%=path%>/images/open.jpg";
					for(var i=0;i<users.length;i++){
						users[i].parentNode.style.display="";
					}
				}
			}
		</script>
	</head>
	<body>
		<html:form action="setRegusers">
		<html:hidden property="projectId" value="<%=projectId %>"/>
		<table>	
			<logic:iterate id="element" name="ReguserRoles">
		<script  language="javascript">
			var currentname= "<bean:write name='element' property='role.roleId'/>";
			if  ( name != currentname )
			{
				name = currentname;
				document.write("<tr><td>");
				document.write("<img id='"+name+"'src='<%=path%>/images/open.jpg' onclick='showUser("+name+");'><bean:write name='element' property='role.roleName'/>");
				document.write("</td></tr>");
				var	content='<tr><td name="<bean:write name='element' property='role.roleId'/>"><html:multibox  property="projectReguserRoleIds"><bean:write name="element" property="regUserRoleId"/></html:multibox></td><td><bean:write name="element" property="reguser.regName"/></td><td><bean:write name="element" property="reguser.employee.empName"/></td></tr>';
				document.write(content);
			}
			else
			{
				var	content='<tr><td name="<bean:write name='element' property='role.roleId'/>"><html:multibox  property="projectReguserRoleIds"><bean:write name="element" property="regUserRoleId"/></html:multibox></td><td><bean:write name="element" property="reguser.regName"/></td><td><bean:write name="element" property="reguser.employee.empName"/></td></tr>';
				document.write(content);
			}
		</script>			
			
			</logic:iterate>
		</table>
			<html:submit/>
		</html:form>
	</body>
</html:html>

